<?php
namespace Orm\Product;

class ProductModel extends \Base\BaseOrmModel{

    function __construct()
    {
        parent::__construct();
        $this->table = 't_product';
    }

    public function loadValidById($id)
    {
        $id = (int) $id;
        $result = $this->fetchOne('*', "`id`={$id} AND `is_del` = 0 AND `status` = ".\Orm\Product\ProductClass::STATUS_VALID);
        if ($result) {
            return $result;
        }
        throw new \Base\Exception\NoRecordException("No record find by id [{$id}]");
    }
}